#include <vector>
#include <iostream>
using namespace std;
class Solution
{
public:
    vector<vector<int>> generateMatrix(int n)
    {
        vector<vector<int>> ans(n, vector<int>(n));
        int num = 1;
        int lt = 0, rb = n - 1;
        while (lt <= rb)
        {
            for (int i = lt; i <= rb; i++)
            {
                ans[lt][i] = num++;
            }
            for (int i = lt + 1; i < rb; i++)
            {
                ans[i][rb] = num++;
            }
            for (int i = rb; i > lt; i--)
            {
                ans[rb][i] = num++;
            }
            for (int i = rb; i > lt; i--)
            {
                ans[i][lt] = num++;
            }
            lt++;
            rb--;
        }
        return ans;
    }
};
int main(int argc, char const *argv[])
{
    int n = 10;
    vector<vector<int>> result = Solution().generateMatrix(n);
    // cout << "[";
    for (int i = 0; i < result.size(); i++)
    {
        cout << "[";

        for (int j = 0; j < result[i].size(); j++)
        {
            cout << result[i][j] << ",";
        }
        cout << "]" << endl;
    }
    // cout << "]";
    return 0;
}
